package org.chaiyi.template.core.framework.swagger;


import io.swagger.v3.oas.models.PathItem;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SwaggerConfig {

    @Bean
    public GroupedOpenApi group1() {
        return GroupedOpenApi.builder()
                .group("businessGroup")
                .pathsToMatch("/**")
                .build();
    }

    @Bean
    public GroupedOpenApi crudGroup() {
        return GroupedOpenApi.builder()
                .group("crudGroup")
                .addOpenApiCustomizer(openApi -> {

                    OperationApiInfo pop = RouterFunctionOperationContext.pop();
                    while (pop != null){
                        pop.buildPathItem(openApi);
                        pop = RouterFunctionOperationContext.pop();
                    }

                })
                .pathsToExclude("/**")
                .build();
    }
}
